package com.techzhi.addres_score.service.impl;


import com.techzhi.addres_score.mapper.AreaCodeMapper;
import com.techzhi.addres_score.model.AreaCode;
import com.techzhi.addres_score.service.AddressService;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import java.util.List;


@Slf4j
@Service
@NoArgsConstructor
@AllArgsConstructor
public class AddressServiceImpl implements AddressService {

    @Autowired
    private AreaCodeMapper areaCodeMapper;

    @Autowired
    private RedisTemplate<String, Object> redisTemplate;


    @Override
    @Cacheable(value = "areabypcode", key = "#pcode")
    public List<AreaCode> getAreaByPCode(Long pcode) {
        log.info("从数据库加载地区pCode[{}]数据", pcode);
        return areaCodeMapper.selectAreaByPCode(pcode);
    }

}